package com.atguigu.tingshu.user.rpc;

import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.user.UserSubscribe;
import com.atguigu.tingshu.model.user.VipServiceConfig;
import com.atguigu.tingshu.user.service.UserInfoService;
import com.atguigu.tingshu.user.service.VipServiceConfigService;
import com.atguigu.tingshu.vo.user.UserInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/rpc/inner/userInfo")
public class UserInfoRpcController {

    @Autowired
    private UserInfoService userInfoService;

    @Autowired
    private VipServiceConfigService vipServiceConfigService;

    @GetMapping("/getUserInfo/{userId}")
    public Result<UserInfoVo> getUserInfo(@PathVariable Long userId){
        return Result.ok(userInfoService.getUserInfo(userId));
    }

    @GetMapping("/getUserPaidTrackInAlbum/{albumId}/{userId}")
    Result<Map<Long, String>> getUserPaidTrackInAlbum(
            @PathVariable Long albumId,
            @PathVariable Long userId){
        Map<Long, String> map = userInfoService.getUserPaidTrackInAlbum(albumId,userId);
        return Result.ok(map);
    }

    @GetMapping("/getUserPaidAlbumById/{albumId}/{userId}")
    Result<Boolean> getUserPaidAlbumById(
            @PathVariable Long albumId,
            @PathVariable Long userId){
        return Result.ok(userInfoService.getUserPaidAlbumById(albumId,userId));
    }

    @GetMapping("/getVipServiceConfig/{itemId}")
    Result<VipServiceConfig> getVipServiceConfig(@PathVariable Long itemId){
        return Result.ok(vipServiceConfigService.getById(itemId));
    }
}
